package com.mgg.auth.social;

import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;

/**
 * @Author lijun
 * @Date: 2018-09-04 12:00:00
 */
public class MggSpringSocialConfigurer extends SpringSocialConfigurer {
	
	private String filterProcessesUrl;
	
	private SocialAuthenticationFilterPostProcesser socialAuthenticationFilterPostProcesser;
	
	public MggSpringSocialConfigurer(String filterProcessesUrl) {
		this.filterProcessesUrl = filterProcessesUrl;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	protected <T> T postProcess(T object) {
		SocialAuthenticationFilter filter = (SocialAuthenticationFilter) super.postProcess(object);
		filter.setFilterProcessesUrl(filterProcessesUrl);
		if (socialAuthenticationFilterPostProcesser != null) {
			socialAuthenticationFilterPostProcesser.process(filter);
		}
		return (T) filter;
	}

	public String getFilterProcessesUrl() {
		return filterProcessesUrl;
	}

	public void setFilterProcessesUrl(String filterProcessesUrl) {
		this.filterProcessesUrl = filterProcessesUrl;
	}

	public SocialAuthenticationFilterPostProcesser getSocialAuthenticationFilterPostProcesser() {
		return socialAuthenticationFilterPostProcesser;
	}

	public void setSocialAuthenticationFilterPostProcesser(
			SocialAuthenticationFilterPostProcesser socialAuthenticationFilterPostProcesser) {
		this.socialAuthenticationFilterPostProcesser = socialAuthenticationFilterPostProcesser;
	}
}
